package domeComparable;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-06-03
 * Time: 11:03
 */
class Student implements Comparable<Student> {
    public String name;//姓名
    public int age;//年龄
    public int score;//成绩

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Strudent{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.name.compareTo(o.name);
    }
}

public class Test {
    public static void main(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student("zhangsan",12,89);
        students[1] = new Student("abc",23,34);
        students[2] = new Student("lisi",18,78);
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }
}
